$(function () {
    var price = $.query.get("total");
    $("#totalPrice").val(price);

})

function submitOrder() {
    $.post("/order/submit",$("#orderForm").serialize(),function (info) {
        if(info == "ok"){
            location.href="/html/user/success.html";
        }
        else{
            layui.use('layer', function(){
                var layer = layui.layer;

                //将json字符串转化为json对象
                var errorList = JSON.parse(info);
                var str = "";
                for(var i=0;i<errorList.length;i++){
                    var obj = errorList[i];
                    //${obj.field}，错误信息：${obj.defaultMessage}
                    var errorInfo = obj.defaultMessage;
                    var textId = "#"+obj.field;
                    layer.tips(errorInfo,textId,  //显示tips的元素
                        {
                            tips: [2,'#3595CC'],   //定义tips的颜色和方向
                            time: 2000 ,             //2秒后自动关闭
                            tipsMore:true           //允许出现多个tips
                        });
                }
            });

        }
    })
}